package com.example.kotlindemo_room

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.room.*
import java.util.*


@Dao
interface StudentDao {

    @Insert
    abstract fun insertStudent(s: Student)

    @Delete
    abstract fun deletStudent(s: Student)

    @Query("DELETE FROM Student")
    abstract fun deletAllStudent()

    //删除指定名字的学生
    @Query("DELETE FROM Student WHERE name = :name")
    abstract fun deletStudentForName(name: String)

    @Update
    abstract fun upDateStudent(s: Student)

    @Query("SELECT * FROM Student")
    abstract fun getAllStudent(): LiveData<List<Student>>

    @Query("SELECT * FROM Student")
    abstract fun getAllStudent2(): List<Student>

    @Query("SELECT * FROM Student WHERE id = :id")
    abstract fun getStudentById(id: Int): List<Student>


}